		<?php $this->load->view('layout/lib_chart');?>
		
		<?php 
		if(isset($_GET['act']) && $_GET['act'] == 'Expense')
		{
			if(isset($row["dependants"]))
			{
				$durations = $row['dependants'];
				$FB = 0;
				foreach($row['loans'] as $k => $v){
					$A	= $v['amount_per_month'];
					$D	= $v['duration'];
					$FB+=$A*$D;
				}
				
				foreach($durations as $k => $v){
					$A	= $v['amount_per_month'];
					$D	= $v['duration'];
					$FB+=$A*$D;
				}
			}
		}
		else
		{
			if(isset($row["number_years"]))
				$FB	=	$row['number_years']*($row['percent_of_protection']/100)*$row['yearly_income'];
		}
		$current_year	=	date('Y');
		
		$cats[]	=	$current_year;
		
		$cats	=	doi_cho($cats,$current_year);
		
		foreach($endowments as $k => $v){
			$cats=doi_cho($cats,$v->maturity_year);
			
		}
		
		foreach($terms as $k =>$v){
			$year	=	$v->policy_incepted + $v->policy_term;
			$cats=doi_cho($cats,$year);
		}
		
		foreach($wls as $k =>$v){
			$year	=	$v->policy_incepted + $v->policy_term;
			$cats=doi_cho($cats,$year);
			if($v->step_up_booster==1){
				$cats=doi_cho($cats,$v->year_start);
				$cats=doi_cho($cats,$v->year_end);
			}
		}
		
		foreach($ilps as $k => $v){
			$year	=	$v->policy_incepted + $v->policy_term;
			$cats=doi_cho($cats,$year);
		}
		
		//print_r($cats);
		$data_g	=	array();
		foreach($cats as $y){
			$tmp_ec	=	0;
			$tmp_ec	=	$this->common_model->get_result_existing_coverage($y);
			$tmp_ch	=	$this->current_holding_model->return_value_by_year($y);
			$data_g[]=array(intval($y),intval($tmp_ec[0])+intval($tmp_ch));
			//echo $tmp_ec[0].'|'.$tmp_ch.'+++++';
		}
		
		$data_g	=	json_encode($data_g);
		//print_r($data_g);
		
		
		$birth_year		=	date('Y',strtotime($_SESSION['customer']['date_of_birth']));
		$last_year		=	$birth_year+100;
		$x = 0;
		$curr_hold_1	=	$this->current_holding_model->return_value_by_year($current_year);
		//echo $curr_hold_1;
		$existing_converage	=	$this->common_model->get_result_existing_coverage($current_year);
		$sad_1	=	$existing_converage[0];
		$g1	=	$curr_hold_1+$sad_1;
		//print_r($existing_converage);
		//echo $g1.'|'.$curr_hold_1.'|'.$g1;
		/*
		echo '<pre>';
		print_r($Y);
		echo '</pre>';
		*/
		
		//$Y	=	json_encode($Y);
		?>
		<!-- 2. Add the JavaScript to initialize the chart on document ready -->
		<script type="text/javascript">
		
			

			var chart1,chart2,chart3,chart4;
			$(document).ready(function() {
				chart1 = new Highcharts.Chart({
					chart: {
						renderTo: 'container1',
						defaultSeriesType: 'spline',
						inverted: false,
						//width: 400,
						style: {
							//margin: '0 auto'
						}
					},
					title: {
						text: '<?php echo(isset($_GET['act']) && $_GET['act']=='Expense' ? 'Expense Approach' : 'Income Approach');?>'
					},
					subtitle: {
						style: {
							position: 'absolute',
							right: '0px',
							bottom: '10px'
						}
					},
					xAxis: {
						reversed: false,
						title: {
							enabled: true,
							text: 'PI+t'
						},
						labels: {
							formatter: function() {
								return this.value +'';
							}
						},
						maxPadding: 0.05,
						//showLastLabel: true,
						min : 2011,
						max : <?php echo 2070;?>
					},
					yAxis: {
						title: {
							text: 'FB'
						},
						labels: {
							formatter: function() {
								return this.value + '';
							}
						},
						lineWidth: 2,
						min : 0
						
					},
					legend: {
						enabled: false
					},
					tooltip: {
						formatter: function() {
							return ''+
								this.y +' / '+ this.x +'';
						}
					},
					plotOptions: {
						spline: {
							marker: {
								enable: false
							}
						}
					},
					series: [
					{
						name: 'FB',
						data: [[<?php echo $current_year?>,<?php echo $FB;?>],[<?php echo $last_year;?>,<?php echo $FB;?>]]
					},
					{
						name: 'Protection Against Death',
						data: <?php echo $data_g;?>,
						type: 'line'
					}
					]
				});
			});
				
		</script>
		<!-- 3. Add the container -->
		<table>
			<tr>
				<td><div id="container1" style="width: 800px; height: 400px; margin: 0 auto"></div></td>
			</tr>
			
		</table>
		